/**
 * @param {number[]} rowSum
 * @param {number[]} colSum
 * @return {number[][]}
 */
var restoreMatrix = function (rowSum, colSum) {
  let row = rowSum.length,
    col = colSum.length
  let arr = new Array(row).fill(0).map(() => new Array(col).fill(0))
  for (let i = 0; i < row; i++) {
    for (let j = 0; j < col; j++) {
      arr[i][j] = Math.min(rowSum[i],colSum[j])
      rowSum[i]-=arr[i][j]
      colSum[j]-=arr[i][j]
    }
  }
  return arr
}

restoreMatrix([14,9],[6,9,8])
